<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<style type="text/css">
			.mui-content {
				width: 100%;
				box-shadow: none;
				background-color: #EFEFF4;
			}
			
			.content-item {
				background-color: #FFFFFF;
				width: 100%;
				padding: 3% 5%;
				color: black;
			}
			
			.content-item1 {
				margin-top: 5%;
				padding-right: 10%;
			}
			
			#nnamae,
			#qianname,
			#phonenum {
				color: #939393;
				font-size: 80%;
				float: right;
			}
			
			.hr-div {
				border-bottom: 1px solid #EAEAEA;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav" id="header">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" id="mui-action-back"></a>
			<h1 class="mui-title">设置</h1>
		</header>

		<div class="mui-content" id="content">

			<div class="content-item content-item1 hr-div" id="nickdiv">
				昵称
				<span id="nnamae"></span>
			</div>

			<div class="content-item" id="qiannamediv">
				<span id="">个性签名</span>
				<span id="qianname"></span>
			</div>


			<div class="content-item content-item1 hr-div" id="phonediv">
				<span>手机号</span>
				<img src="../images/suo.png" style="width: 6%;float: right;" />
				<span id="phonenum"></span>
			</div>

			<div class="content-item hr-div" id="newdiv">
				<span id="">新消息提醒</span>
			</div>

			<div class="content-item" id="mpassworddiv">
				<span id="">修改密码</span>
			</div>

			<div class="content-item content-item1 hr-div" id="toggleteldiv">
				<span id="">切换账号</span>
			</div>

			<div class="content-item" id="backdiv">
				<span id="">退出</span>
			</div>
		</div>

		<script src="../js/mui.min.js"></script>
		<script src="../js/immersed.js"></script>
		<script src="../js/app.js"></script>
		<script src="../js/vue.min.js"></script>
		<script type="text/javascript">
			(function($) {
				$.init();

				$.plusReady(function() {
					starbar();
					plus.navigator.setStatusBarStyle("dark");

					var nick = document.getElementById('nnamae');
					var aword = document.getElementById('qianname');
					var tel = document.getElementById('phonenum');

					//点击返回事件
					var old_back = mui.back;
					mui.back = function() {
						old_back();
						var preView = plus.webview.currentWebview().opener(); //触发上一个页面刷新图片事件
						mui.fire(preView, 'changeto', {
							nick: nick.textContent,
							aword: aword.textContent
						});
						plus.navigator.setStatusBarStyle('light');
					}

					$.ajax('https://www.lunyuwang.com/mineController/querySetting', {
						data: {
							lyuser_Card: plus.storage.getItem("card")
						},
						crossDomain: true, //强制使用5+跨域
						dataType: 'json', //服务器返回json格式数据
						type: 'get', //HTTP请求类型
						timeout: 10000, //超时时间设置为10秒；
						//processData: false,
						headers: {
							'Content-Type': 'application/x-www-form-urlencoded'
						},
						success: function(data) {
							var cont = data.userSetting;
							nick.textContent = cont.lyuser_NickName,
								aword.textContent = cont.lyuser_AWord,
								tel.textContent = cont.lyuser_Tel
						}

					})
					document.getElementById('mui-action-back').addEventListener('tap', function() {
						$.back();
					})

					document.getElementById('nickdiv').addEventListener('tap', function() {
						var nick = document.getElementById('nnamae').textContent;
						$.openWindow({
							url: 'install/makeNickname.html',
							id: 'install/makeNickname.html',
							extras: {
								nick: nick
							}
						})
					})

					document.getElementById('qiannamediv').addEventListener('tap', function() {
						var qname = document.getElementById('qianname').textContent;
						$.openWindow({
							url: 'install/personallyname.html',
							id: 'install/personallyname.html',
							extras: {
								qname: qname
							}
						})
					})

					document.getElementById('phonediv').addEventListener('tap', function() {
						var jphonenum = document.getElementById('phonenum').textContent;
						$.openWindow({
							url: 'install/makephonenum.html',
							id: 'install/makephonenum.html',
							extras: {
								jphonenum: jphonenum
							}
						})
					})

					document.getElementById('newdiv').addEventListener('tap', function() {
						$.openWindow({
							url: 'install/newcall.html',
							id: 'install/newcall.html'
						})
					})

					document.getElementById('mpassworddiv').addEventListener('tap', function() {
						$.openWindow({
							url: 'install/makepassword.html',
							id: 'install/makepassword.html'
						})
					})

					document.getElementById('toggleteldiv').addEventListener('tap', function() {
						var btn = ["确定", "取消"];
						$.confirm('确认切换到其他账号？', 'lun yu', btn, function(e) {
							if(e.index == 0) {　　
								var wvs = plus.webview.all();　　 //所有窗口对象
								　　
								var launch = plus.webview.getLaunchWebview();　　 //首页窗口对象
								　　
								var self = plus.webview.currentWebview();　　 //当前窗口对象
								　　
								for(var i = 0, len = wvs.length; i < len; i++) {　　　 // 首页以及当前窗口对象，不关闭；
									　　
									if(wvs[i].id === self.id || wvs[i].id === launch.id) {　　　　　　 //选定某一页不关wvs[i].id === localStorage.homeWebId
										　　　　　
										continue;　　
									} else {　　　　　
										wvs[i].close('none');　　 //关闭中间的窗口对象，为防止闪屏，不使用动画效果；
									}
								}
								$.openWindow({
									url: "../index.html",
									id: "../index.html"
								})
								plus.webview.currentWebview().close();
							}
						});
					})

					document.getElementById('backdiv').addEventListener('tap', function() {
						var btn = ["确定", "取消"];
						$.confirm('确认退出？', 'lun yu', btn, function(e) {
							if(e.index == 0) {
								app.userLogout();
								//								plus.runtime.quit();
								mui.openWindow("../index.html", "../index.html");
							}
						});
					})

					window.addEventListener('install', function(event) {
						if(event.detail.nickname) {
							nick.textContent = event.detail.nickname;
						} else if(event.detail.aword) {
							aword.textContent = event.detail.aword;
						} else {
							tel.textContent = event.detail.tel;
						}
					})

				})
			})(mui);
		</script>
	</body>

</html>